package com.central.apps.dao.MaterialInventory;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface QueryDao {
    //查询当月需要结算的库存
    @Select("select es.binnum,es.batchnum,es.curbal,ry.storenum,ry.storedesc,ry.itemnum,ry.itemdesc,ry.unit,st.stdcost,st.avgcost " +
            "from gq_invbalances es " +
            "left join gq_inventory ry on es.storenum = ry.storenum and es.itemnum = ry.itemnum " +
            "left join gq_invcost st on es.storenum = st.storenum and es.itemnum = st.itemnum and es.batchnum = st.batchnum " +
            "where curbal > 0")
    List<Map<String, Object>> findInvbalances();

    @Insert("insert into gq_queryline (itemnum,itemdesc,binnum,lotnum,curbal,unit,queryid,avgcost,stdcost,linecost) " +
            "values(#{itemnum},#{itemdesc},#{binnum},#{batchnum},#{curbal},#{unit},#{queryid},#{avgcost},#{stdcost},#{linecost})")
    void insertToQueryline(Map<String, Object> params);

    @Update("update gq_query set totalnumber = #{totalnumber},totalcost = #{totalcost}")
    void updateQuery(Integer totalnumber, String totalcost);

//    @Insert("insert into select")
}
